﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MySoft.Data.Ext.DataHandel
{
    public class OraBaseDao<T> : BaseDao<T> where T : Entity
    {
        public override bool Add_Entity(T entity)
        {
            int retVal = 0;
            using (DbTrans trans = db.BeginTrans())
            {
                retVal = trans.Save(entity);
                trans.Commit();
            }
            return retVal > 0;
        }

        public override bool Update_Entity(T entity)
        {
            entity.Attach();

            int retVal = 0;
            using (DbTrans trans = db.BeginTrans())
            {
                retVal = trans.Save(entity);
                trans.Commit();
            }
            return retVal > 0;
        }

        public override bool Insert_Or_Update(T entity)
        {
            int retVal = 0;
            using (DbTrans trans = db.BeginTrans())
            {
                retVal = trans.InsertOrUpdate(entity);
                trans.Commit();
            }
            return retVal > 0;
        }
    }
}
